﻿using System;
using AddinExpress.OL;
using Microsoft.Office.Core;

namespace uTILLIty.Outlook.FlexFileAddIn
{
	partial class FlexFile
	{
		private void FormsManagerOnInitialize()
		{
			#region Events Initialization

			// TODO: See the Class Reference for the complete list of events of the ADXOlFormsManager class
			
			FormsManager.ADXBeforeFormInstanceCreate += FormsManager_ADXBeforeFormInstanceCreate;
			FormsManager.ADXBeforeFolderSwitchEx += FormsManager_ADXBeforeFolderSwitchEx;
			FormsManager.ADXFolderSwitch += FormsManager_ADXFolderSwitch;
			FormsManager.ADXFolderSwitchEx += FormsManager_ADXFolderSwitchEx;
			FormsManager.ADXNewInspector += FormsManager_ADXNewInspector;
			FormsManager.OnError += FormsManager_OnError;

			#endregion

			#region PaneIntegration

			// TODO: Use the NavRegionWorkspaceItem properties to configure the region's location, appearance and behavior.
			// See the "The UI Mechanics" chapter of the Add-in Express Developer's Guide for more information.

			PaneIntegrationItem = new ADXOlFormsCollectionItem();
			PaneIntegrationItem.ExplorerLayout = ADXOlExplorerLayout.BottomNavigationPane;
			PaneIntegrationItem.ExplorerItemTypes = ADXOlExplorerItemTypes.olMailItem;
			PaneIntegrationItem.AlwaysShowHeader = true;
			PaneIntegrationItem.IsDragDropAllowed = true;
			PaneIntegrationItem.ExplorerAllowedDropRegions = ADXOlExplorerAllowedDropRegions.BottomNavigationPane;
			PaneIntegrationItem.UseOfficeThemeForBackground = true;
			PaneIntegrationItem.FormClassName = typeof(PaneIntegration).FullName;
			PaneIntegrationItem.Cached = ADXOlCachingStrategy.OneInstanceForAllFolders;
			FormsManager.Items.Add(PaneIntegrationItem);

			#endregion
		}

		#region ADXBeforeFormInstanceCreate

		/// <summary>
		/// Use this event to cancel the creation of a form instance.
		/// </summary>
		/// <remarks> To prevent a form instance from being shown, you set ADXOlFom.Visible = false 
		/// in the ADXBeforeFormShow event of the ADXOlForm class. </remarks>
		private void FormsManager_ADXBeforeFormInstanceCreate(object sender, BeforeFormInstanceCreateEventArgs args)
		{
		}

		#endregion

		#region ADXBeforeFolderSwitchEx

		/// <summary>
		/// Occurs before an Outlook explorer goes to a new folder,
		/// either as a result of user action or through program code.
		/// </summary>
		private void FormsManager_ADXBeforeFolderSwitchEx(object sender, BeforeFolderSwitchExEventArgs args)
		{
		}

		#endregion

		#region ADXFolderSwitch

		/// <summary>
		/// Occurs before an Outlook explorer goes to a new folder,
		/// either as a result of user action or through program code.
		/// </summary>
		private void FormsManager_ADXFolderSwitch(object sender, FolderSwitchEventArgs args)
		{
		}

		#endregion

		#region ADXFolderSwitchEx

		/// <summary>
		/// Occurs when an Outlook explorer goes to a new folder, 
		/// either as a result of user action or through program code.
		/// </summary>
		/// <remarks>
		/// Set args.ShowForm = False to prevent any ADXOlForm from display. This also prevents 
		/// the ADXFolderSwitch events from firing.
		/// <para>To prevent a given form instance from being shown, you set ADXOlFom.Visible = false
		/// in the ADXBeforeFormShow event of the corresponding ADXOlForm. </para>
		/// </remarks>
		private void FormsManager_ADXFolderSwitchEx(object sender, FolderSwitchExEventArgs args)
		{
		}

		#endregion

		#region ADXNewInspector

		/// <summary>
		/// Occurs whenever a new inspector window is opened,
		/// either as a result of user action or through program code.
		/// </summary>
		private void FormsManager_ADXNewInspector(object inspectorObj)
		{
#if DEBUG
      System.Diagnostics.Debug.WriteLine("FormsManager_ADXNewInspector");
#endif
		}

		#endregion

		#region OnError

		/// <summary>
		/// Occurs when ADXOlFormaManager generates an exception.
		/// </summary>
		private void FormsManager_OnError(object sender, ErrorEventArgs args)
		{
		}

		#endregion

		#region RequestService

		/// <summary>
		/// Required method for DockRight, DockLeft, DockTop and DockBottom layout support.
		/// </summary>
		protected override object RequestService(Guid serviceGuid)
		{
			if (serviceGuid == typeof(ICustomTaskPaneConsumer).GUID)
			{
				return CTPFactoryGettingTaskPane.Instance;
			}
			return base.RequestService(serviceGuid);
		}

		#endregion
	}
}